module diansha {
	export class main extends eui.Component implements eui.UIComponent {
		private pro: diansha.progressbar;
		tupo: eui.Button;
		public constructor() {
			super();

		}

		protected partAdded(partName: string, instance: any): void {
			super.partAdded(partName, instance);
		}


		protected childrenCreated(): void {
			super.childrenCreated();
			// this.pro = new diansha.progressbar();
			// this.addChild(this.pro);
			this.init();
			this.farm();
			this.tupo.addEventListener(egret.TouchEvent.TOUCH_TAP, this.tupotouch, this)
			this.tupo.enabled = false;

		}
		/**
		 * 点击tupo按钮
		 * 确保如下:
		 * 先升ji在获取max
		 */
		private tupotouch() {
			/**
			 * 实质升级
			 */
			let s: diansha.NUMlast = diansha.NUM.getinstance().up();
			console.log(s)
			this.tupo.enabled = false

			/**
			 * 更新显示
			 */
			this.pro.setmax(s.max);
			this.pro.f5();


		}

		private init() {
			this.pro.setmax(diansha.NUM.getinstance().max);
			this.pro.setvalue(diansha.shuzi_factory.getinstance().get(0, "n"));
		}
		private farm() {

			setInterval(() => {
				let liliangaddpaopao = diansha.paopao_factory.getinstance().get(diansha.NUM.getinstance().one_time_qi, new egret.Point(0, 200), new egret.Point(200, 10), 3000, "哈哈", this.startcall, this.endcall);
				cores.getinstatic().main.addChild(liliangaddpaopao);

			}, 80);


		}
		private startcall() {


		}
		private endcall() {
			cores.getinstatic().main.pro.setvalue(diansha.NUM.getinstance().one_time_qi);

		}

	}
}